import  pymongo

class MongoTesting:

    def __init__(self):
        pass
    
    def _test(self,host):
        try:
            client = pymongo.MongoClient(host,27017,waitQueueTimeoutMS=30,waitQueueMultiple=30)    
            if client.database_names():
                return "[+] : %s mongodb login success database: %s"%(self.host,client.database_names())
                client.close()
            else :
                return '[-] : %s mongodb login failed '%self.host
        except Exception:
            return  "[-] : %s mongodb connect time out"%self.host
    def run(self,host_port):
        #print host_port
        self.host=host_port.keys()[0]
        
        return [self._test(self.host)]

if __name__ =='__main__':
    
    M=MongoTesting()
    print M.run({'2': [27017]})